//
//  A_HNTQYController.m
//  Estate
//
//  Created by heyong on 16/6/16.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "A_HNTQYController.h"
#import "HeadView_1.h"
#import "QianDTableCell.h"
@interface A_HNTQYController ()
{
    NSArray *titleArr;
}
@end

@implementation A_HNTQYController
- (UITableView *)tableView{
    if(_tableView==nil){
        _tableView=[[TPKeyboardAvoidingTableView alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT) style:UITableViewStyleGrouped];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        [_tableView registerNib:[UINib nibWithNibName:@"QianDTableCell" bundle:nil] forCellReuseIdentifier:@"acell"];
    }
    return _tableView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title=@"旁站-混凝土施工-物料信息";
    [self.view addSubview:self.tableView];
    titleArr=@[@"标准养护",@"同条件养护",@"拆模同条件",@"防水混凝土",@"冬施(转常温)",@"其他"];

    //添加右上方提交按钮
    if(self.isEdit){
        self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"wancheng"] style:UIBarButtonItemStyleDone target:self action:@selector(clickSave)];
    }

}
//!!!!:保存视图
- (void)clickSave{
//    NSLog(@"%@",self.dataArr);
    
    self.dataBlock(self.dataArr);
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 6;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 46;
}

//头部视图
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    HeadView_1 *header=[[HeadView_1 alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 46)];
    header.title.text=[NSString stringWithFormat:@"  %@",titleArr[section]];
    if(section%2==0){
        header.title.textColor=[UIColor colorWithRed:0.07 green:0.54 blue:0.49 alpha:1.00];
        header.backgroundColor=[UIColor colorWithRed:0.07 green:0.54 blue:0.49 alpha:1.00];
    }else{
        header.title.textColor=[UIColor colorWithRed:0.64 green:0.25 blue:0.11 alpha:1.00];
        header.backgroundColor=[UIColor colorWithRed:0.64 green:0.25 blue:0.11 alpha:1.00];
    }
    return header;
}

//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    QianDTableCell *cell=[tableView dequeueReusableCellWithIdentifier:@"acell" forIndexPath:indexPath];
    //根据组 获得数据
    NSMutableDictionary *dic=[self.dataArr objectAtIndex:indexPath.section];
    
    if(indexPath.row==0){
        
        cell.textValueChangedBlock=^(NSString *values){
            [dic setValue:values forKey:@"取样组数"];
        };
        
        [cell configWithPlaceholder:@"请输入" andValue:dic[@"取样组数"] andLabel:@"取样组数:" andKeyType: UIKeyboardTypeDefault];
        
    }else if (indexPath.row==1){
        cell.textValueChangedBlock=^(NSString *values){
            [dic setValue:values forKey:@"见证取样单编号"];
        };
        
        [cell configWithPlaceholder:@"请输入" andValue:dic[@"见证取样单编号"] andLabel:@"见证取样单编号:" andKeyType: UIKeyboardTypeDefault];
        

        
    }else{
        
        cell.textValueChangedBlock=^(NSString *values){
            [dic setValue:values forKey:@"试块编号"];
        };
        
        [cell configWithPlaceholder:@"请输入" andValue:dic[@"试块编号"] andLabel:@"试块编号:" andKeyType: UIKeyboardTypeDefault];
        

        
    }
    return cell;
}


@end
